import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/views/index/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path: '/winnersList',
    name: 'WinnersList',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '@/views/winnersList/winnersList.vue')
  },
  {
    path: '/prizeList',
    name: 'PrizeList',
    component: () => import(/* webpackChunkName: "about" */ '@/views/prizeList/prizeList.vue')
  },
  {
    path: '/uploadMyLove',
    name: 'UploadMyLove',
    component: () => import(/* webpackChunkName: "about" */ '@/views/uploadMyLove/uploadMyLove.vue')
  },
  {
    path: '/myLovePage',
    name: 'MyLovePage',
    component: () => import(/* webpackChunkName: "about" */ '@/views/myLovePage/myLovePage.vue')
  },
  {
    path: '/shareMyLove',
    name: 'ShareMyLove',
    component: () => import(/* webpackChunkName: "about" */ '@/views/shareMyLove/shareMyLove.vue')
  },
  {
    path: '/poster',
    name: 'Poster',
    component: () => import(/* webpackChunkName: "about" */ '@/views/shareMyLove/poster/poster.vue')
  },
  {
    path: '/errPage/:type?',
    name: 'ErrPage',
    component: () => import(/* webpackChunkName: "about" */ '@/views/errPage/errPage.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  document.title = to.meta ? to.meta.title || "七夕活动" : "七夕活动"
  next()
})

export default router
